<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="content">houdunren.com</div>
  </body>
</html>

<script>
  let con = prompt("请输入要检测的内容，支持正则");
  let reg = new RegExp(con, "g"); // 第二个参数是模式
  let div = document.querySelector("div");
  div.innerHTML = div.innerHTML.replace(reg, (search) => {
    return `<span style="color:red">${search}</span>`;
  });
</script>
